package cn.tpshion.devops.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.tpshion.devops.config.UserConfig;
import cn.tpshion.devops.domain.dto.LoginDTO;
import cn.tpshion.devops.service.UserService;
import cn.tpshion.devops.util.AssertUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;

@Slf4j
@Service
public class UserServiceImpl implements UserService {

    @Resource
    private UserConfig userConfig;

    @Override
    public void login(LoginDTO dto) {
        AssertUtil.isFalse(userConfig.getUsername().equals(dto.getUsername()), "登录失败，数据不对");
        AssertUtil.isFalse(userConfig.getPassword().equals(dto.getPassword()), "登录失败，数据不对");
        StpUtil.login(userConfig.getUsername());
    }
}
